package adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

import fragments.BaseFragment;

/**
 * Created by Administrator on 15-10-20.
 */
public class CommentFragmentPagerAdapter extends FragmentPagerAdapter {
    private List<BaseFragment> fragments;

    public CommentFragmentPagerAdapter(FragmentManager fm,List<BaseFragment> fragments) {
        super(fm);
        this.fragments=fragments;
    }


    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        int ret=0;
        if(fragments!=null)
        {
            ret=fragments.size();
        }
        return ret;
    }



    public CharSequence getPageTitle(int position) {
        String ret=null;
        //获取当前显示的Fragment对象
        BaseFragment baseFragment= (BaseFragment) fragments.get(position);
        //获取Fragment的标题
        ret= baseFragment.getFragmentTitle();
        return ret;
    }
}
